using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
public partial class pages_TourCategory :PagedPage
{
    #region properties
    public override string RequestString
    {
        get {
            string rg=Request["region"];
            if (rg == null) rg = "";
            return "TourList.aspx?region="+rg+"&page=";
        }
    }
    #endregion
    protected void Page_Load(object sender, EventArgs e)
    {
        
        p = Request["page"];
        totals = 0;
        currentPage = GetPageNumber(p);
       if(!IsPostBack) LoadData();
    }
    public void LoadData()
    {
        TourDAO daoTour = new TourDAO();

        string region = Request["region"];
        if (region == null || region == "")
        {
            rptPopularTour.DataSource = daoTour.GetRecommendedTours(currentPage, pageSize, ref totals, true, ServiceObject.Published);

        }
        else if (region == "southern")
        {
            rptPopularTour.DataSource = daoTour.GetToursByRegion(currentPage, pageSize, ref totals, "Southern", ServiceObject.Published);
        }
        else if (region == "central")
        {
            rptPopularTour.DataSource = daoTour.GetToursByRegion(currentPage, pageSize, ref totals, "Central", ServiceObject.Published);
        }
        else if (region == "northern")
        {
            rptPopularTour.DataSource = daoTour.GetToursByRegion(currentPage, pageSize, ref totals, "Northern", ServiceObject.Published);
        }
        rptPopularTour.DataBind();
        lblPaging.Text = GetPageGrid(totals, pageSize, currentPage);
    }

    /// <summary>
    /// This method is used to set visible value for 'Discount' field
    /// </summary>
    /// <param name="value">discount amount</param>
    /// <returns>Return true if discount greater than 0, else return false. </returns>
    public bool GetDiscountState(object value)
    {
        decimal d = decimal.Parse(value.ToString());
        if (d > 0) return true;
        return false;
    }
    
}
